package com.CNMedical.web.controller.system;

import java.util.List;
import javax.annotation.Resource;

import com.CNMedical.system.domain.vo.AppletKnowledgeCollectVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.CNMedical.common.annotation.Log;
import com.CNMedical.common.core.controller.BaseController;
import com.CNMedical.common.core.domain.AjaxResult;
import com.CNMedical.common.enums.BusinessType;
import com.CNMedical.system.domain.entity.AppletKnowledgeCollect;
import com.CNMedical.system.service.IAppletKnowledgeCollectService;
import com.CNMedical.common.core.page.TableDataInfo;

/**
 * 知识收藏Controller
 * 
 * @author tang
 * @date 2023-03-28
 */
@RestController
@RequestMapping("/system/knowledgeCollect")
public class AppletKnowledgeCollectController extends BaseController
{
    @Resource
    private IAppletKnowledgeCollectService appletKnowledgeCollectService;

    /**
     * 查询知识收藏列表
     */
    @PreAuthorize("@ss.hasPermi('system:knowledgeCollect:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletKnowledgeCollect appletKnowledgeCollect)
    {
        startPage();
        List<AppletKnowledgeCollectVO> list = appletKnowledgeCollectService.selectAppletKnowledgeCollectList(appletKnowledgeCollect);
        return getDataTable(list);
    }

    /**
     * 导出知识收藏列表
     */
//    @PreAuthorize("@ss.hasPermi('system:knowledgeCollect:export')")
//    @Log(title = "知识收藏", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, AppletKnowledgeCollect appletKnowledgeCollect)
//    {
//        List<AppletForumCollectVO> list = appletKnowledgeCollectService.selectAppletKnowledgeCollectList(appletKnowledgeCollect);
//        ExcelUtil<AppletKnowledgeCollect> util = new ExcelUtil<AppletKnowledgeCollect>(AppletKnowledgeCollect.class);
//        util.exportExcel(response, list, "知识收藏数据");
//    }

    /**
     * 获取知识收藏详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:knowledgeCollect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletKnowledgeCollectService.selectAppletKnowledgeCollectById(id));
    }

    /**
     * 新增知识收藏
     */
    @PreAuthorize("@ss.hasPermi('system:knowledgeCollect:add')")
    @Log(title = "知识收藏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletKnowledgeCollect appletKnowledgeCollect)
    {
        return toAjax(appletKnowledgeCollectService.insertAppletKnowledgeCollect(appletKnowledgeCollect));
    }

    /**
     * 修改知识收藏
     */
    @PreAuthorize("@ss.hasPermi('system:knowledgeCollect:edit')")
    @Log(title = "知识收藏", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletKnowledgeCollect appletKnowledgeCollect)
    {
        return toAjax(appletKnowledgeCollectService.updateAppletKnowledgeCollect(appletKnowledgeCollect));
    }

    /**
     * 删除知识收藏
     */
    @PreAuthorize("@ss.hasPermi('system:knowledgeCollect:remove')")
    @Log(title = "知识收藏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletKnowledgeCollectService.deleteAppletKnowledgeCollectByIds(ids));
    }
}
